package com.huawei.mpchartexample.notimportant;

import com.huawei.mpchartexample.ResourceTable;
import ohos.aafwk.ability.Ability;
import ohos.aafwk.content.Intent;
import ohos.aafwk.content.Operation;
import ohos.agp.components.Button;

public class MainAbility extends Ability {
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_main);

        Button lineButton = findComponentById(ResourceTable.Id_lineChartButton);
        lineButton.setClickedListener(component -> {
            Intent newIntent = new Intent();
            Operation operation = new Intent.OperationBuilder()
                    .withDeviceId("")
                    .withBundleName("com.huawei.mpchartexample")
                    .withAbilityName("com.huawei.mpchartexample.LineChartAbility")
                    .build();
            newIntent.setOperation(operation);
            startAbility(newIntent);
        });

        Button barButton = findComponentById(ResourceTable.Id_barChartButton);
        barButton.setClickedListener(component -> {
            Intent newIntent = new Intent();
            Operation operation = new Intent.OperationBuilder()
                    .withDeviceId("")
                    .withBundleName("com.huawei.mpchartexample")
                    .withAbilityName("com.huawei.mpchartexample.BarChartAbility")
                    .build();
            newIntent.setOperation(operation);
            startAbility(newIntent);
        });

        Button pieButton = findComponentById(ResourceTable.Id_pieChartButton);
        pieButton.setClickedListener(component -> {
            Intent newIntent = new Intent();
            Operation operation = new Intent.OperationBuilder()
                    .withDeviceId("")
                    .withBundleName("com.huawei.mpchartexample")
                    .withAbilityName("com.huawei.mpchartexample.PieChartAbility")
                    .build();
            newIntent.setOperation(operation);
            startAbility(newIntent);
        });

        Button radarButton = findComponentById(ResourceTable.Id_radarChartButton);
        radarButton.setClickedListener(component -> {
            Intent newIntent = new Intent();
            Operation operation = new Intent.OperationBuilder()
                    .withDeviceId("")
                    .withBundleName("com.huawei.mpchartexample")
                    .withAbilityName("com.huawei.mpchartexample.RadarChartAbility")
                    .build();
            newIntent.setOperation(operation);
            startAbility(newIntent);
        });

        Button bubbleButton = findComponentById(ResourceTable.Id_bubbleChartButton);
        bubbleButton.setClickedListener(component -> {
            Intent newIntent = new Intent();
            Operation operation = new Intent.OperationBuilder()
                    .withDeviceId("")
                    .withBundleName("com.huawei.mpchartexample")
                    .withAbilityName("com.huawei.mpchartexample.BubbleChartAbility")
                    .build();
            newIntent.setOperation(operation);
            startAbility(newIntent);
        });
    }
}
